/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kungkhies.common.services.kungkhie.validate.xml;

import com.kungkhies.common.services.kungkhie.parse.KungkhieParseService;
import com.kungkhies.xml.schema.kungkhie.KungkhieDocument;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import static org.junit.Assert.*;

/**
 *
 * @author clayton
 */
//@RunWith(value=BlockJUnit4ClassRunner.class)
public class KungkhieXmlValidateServiceImplTest_ArcList
{
    public KungkhieXmlValidateServiceImplTest_ArcList()
    {
    }
    
    @BeforeClass
    public static void setUpClass()
    {
    }
    
    @AfterClass
    public static void tearDownClass()
    {
    }
    
    @Before
    public void setUp()
    {
    }
    
    @After
    public void tearDown()
    {
    }

    

    /**
     * Test of validateKungkhieType method, of class KungkhieXmlValidateServiceImpl.
     */
    @Test
    public void testValidateKungkhieInfoUrl() throws Exception
    {
        System.out.println("validateKungkhieInfoUrl");
        KungkhieDocument kungkhieDocument = null;
        KungkhieXmlValidateServiceImpl instance = new KungkhieXmlValidateServiceImpl();
        String pathToFile = "resources/example-kungkhie-1.xml";
        String filename = "validateContent.txt";
        kungkhieDocument = instance.createKungkhieDocument(pathToFile, filename);
        
        String expected = "http://www.erewhon.ac.uk/info.htm";
        
        String actual = kungkhieDocument.getKungkhie().getInfoUrlArray(0);
        
        assertEquals(expected, actual);
    }
    
    /**
     * Test of validateKungkhieType method, of class KungkhieXmlValidateServiceImpl.
     */
    
    @Test
    public void testValidateKungkhieInfoUrl_ValidForm() throws Exception
    {
        System.out.println("validateKungkhieInfoUrl_ValidForm");
        KungkhieDocument kungkhieDocument = null;
        KungkhieXmlValidateServiceImpl instance = new KungkhieXmlValidateServiceImpl();
        String pathToFile = "resources/example-kungkhie-1.xml";
        String filename = "validateContent.txt";
        kungkhieDocument = instance.createKungkhieDocument(pathToFile, filename);
        
        String actual = kungkhieDocument.getKungkhie().getInfoUrlArray(0);
        
        System.out.println(actual.toString());
        
        boolean isValidUrl = true;
        
        try
        {
            URL url = new URL(actual);
            
        }
        catch (MalformedURLException malformedURLException)
        {
            isValidUrl = false;
        }
        
//        boolean expected = instance.
        
        assertEquals(isValidUrl, true);
        
        //URL url2 = new URL("blah");
    }

    
}
